/**
 * Created by Jessica on 17/3/6.
 */
var plugins=[];


var glob = require('glob');

var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var htmlchunk = function(globPath) {
    var files = glob.sync(globPath);
    var template, filename;

    for (var i = 0; i < files.length; i++) {
        template = files[i];
        filename = path.dirname(template.replace(template.split('/')[0] + '/', '')) + '/index';
        console.log(filename);
        plugins.push(new HtmlWebpackPlugin({
                filename: filename + '.html',
                template: template,
                inject:'head',
                chunks: [filename]
            }));
        // entriesObj[path.join(dirname, basename)] = './' + entry;
    }
    return plugins;
};

console.log(htmlchunk('src/pages/**/*.html'));
// console.log(entries('src/pages/**/*.js'));
// new HtmlWebpackPlugin({
//     filename: 'pages/index/index.html',
//     template: './src/pages/index/index.html',
//     inject:'head',
//     chunks: ['pages/index/index']
// }),